package com.ysstech.activiti.controller;

import java.util.Map;

import com.ysstech.activiti.service.ActivitiHistoryService;
import com.ysstech.common.controller.BaseController;
import com.ysstech.common.util.resultutil.RestResult;
import com.ysstech.common.util.resultutil.ResultGenerator;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Slf4j
@Controller
@Api(tags = "流程历史api")
@RequestMapping(value = "/activitiHistory")
public class ActivitiHistoryController extends BaseController {
    @Autowired
    private ActivitiHistoryService activitiHistoryService;


    @RequestMapping(value = "/page")
    public String history() throws Exception {
        return "activiti/history";
    }
    /**
     * 通过用户id查询启动的或者完成的流程实例
     *
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/queryFlow")
    @ResponseBody
    public RestResult startProcessFlow(String page, String rows, String key) throws Exception {
        Map<String, Object> map = activitiHistoryService.queryFlow(redisCacheManager.getLoginUserInfo().getLoginId(), this.getPage(page, rows), key);
        return ResultGenerator.getSuccessResult("查询我启动流程成功！", map);
    }
}
